<!DOCTYPE html>
<html lang="zh"xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title>首页 - 天才(genius)后台管理系统</title>
    <link rel="icon" th:href="@{favicon.ico}" type="image/ico">
    <link href="css/bootstrap.min.css" th:href="@{~/css/bootstrap.min.css}" rel="stylesheet">
    <link href="css/materialdesignicons.min.css" th:href="@{~/css/materialdesignicons.min.css}" rel="stylesheet">
    <link href="css/style.min.css" th:href="@{~/css/style.min.css}" rel="stylesheet">
    <!--标签插件-->
    <link rel="stylesheet" th:href="@{~/js/jquery-tags-input/jquery.tagsinput.min.css}" href="js/jquery-tags-input/jquery.tagsinput.min.css">
</head>

<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <aside th:include="left :: common" class="lyear-layout-sidebar">
        </aside>
        <!--End 左侧导航-->
        <!--头部信息-->
        <header th:include="head :: common" class="lyear-layout-header">
        </header>
        <!--End 头部信息-->
        <!--页面主要内容-->
        <main class="lyear-layout-content">
            <form action="/study-commodity/Commodityadd" enctype="multipart/form-data" method="post" id="save_emp">
                <div class="container-fluid">

                    <div class="row">
                        <div class="col-lg-12">
                            <div class="card">
                                <div class="card-body">

                                    <form action="#!" method="post" class="row">
                                        <div class="form-group col-md-6">
                                            <label >创建人</label>
                                            <input type="hidden" name="commodityCreateEmpId" th:value="${session.USER.id}">
                                            <input type="text" disabled="disabled" class="form-control" th:value="${session.USER.empName}"/>
                                        </div>
                                        <div class="form-group col-md-12">
                                            <!--<label >商品编号</label>
                                            <input type="text" class="form-control" th:onblur="save()" onblur="save()" id="id" name="id"  />-->

                                            <div class="form-group col-md-12 alert alert-danger" role="alert"  hidden="true" id="msgmore">

                                            </div>

                                            <div class="form-group col-md-12">
                                                <label>商品名称</label>
                                                <input id="commodityName" onblur="save()" class="form-control" name="commodityName" rows="5"  placeholder="请输入商品名称"></input>
                                            </div>

                                            <div class="form-group col-md-12">
                                                <label>商品积分</label>
                                                <input id="commodityIntegral" onblur="save()" class="form-control" name="commodityIntegral" rows="5"  placeholder="请输入商品积分"></input>
                                            </div>
                                            <div class="form-group col-md-12">
                                                <label>商品数量</label>
                                                <input id="commodityCont" onblur="save()" class="form-control" name="commodityCont" rows="5"  placeholder="请输入商品数量"></input>
                                            </div>

                                            <div class="form-group col-md-12">
                                                <label>商品图片</label>

                                                <input type="file" name="file" class="form-control" th:onblur="save()" onblur="save()" id="commodityImage"   placeholder="请输入商品图片" />
                                                <input type="text" id="in1" style="display: none" name="commodityImage">
                                            </div>


                                            <button type="button" class="btn btn-primary" id="svemp" data-toggle="modal" data-target=".bs-example-modal-sm">保存</button>

                                            <div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
                                                <div class="modal-dialog modal-sm" role="document">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                                                            <h4 class="modal-title" id="myLargeModalLabel">商品新增</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            是否确认添加😊
                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                                                            <button type="button" onclick="add()" class="btn btn-primary">点击保存</button>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>

                                            <button type='button' class='btn btn-default' onclick="javascript:history.back(-1);return false;">返 回</button>
                                        </div>
                                    </form>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </main>
    </div>
    <!--End 页面主要内容-->
</div>
</div>
<script type="text/javascript" th:src="@{~/js/jquery.min.js}" src="js/jquery.min.js"></script>
<script type="text/javascript" th:src="@{~/js/bootstrap.min.js}" src="js/bootstrap.min.js"></script>
<script type="text/javascript" th:src="@{~/js/perfect-scrollbar.min.js}" src="js/perfect-scrollbar.min.js"></script>
<script src="/js/jconfirm/jquery-confirm.min.js" th:src="@{~/js/jconfirm/jquery-confirm.min.js}"></script>
<script type="text/javascript" th:src="@{~/js/main.min.js}" src="js/main.min.js"></script>

<!--图表插件-->
<script type="text/javascript" th:src="@{~/js/Chart.js}" src="js/Chart.js"></script>
<script type="text/javascript">



    function save() {
        $("#svemp").attr({"disabled":"disabled"});

        var commodityName =$("#commodityName").val();
        var commodityIntegral =$("#commodityIntegral").val();
        var commodityCont =$("#commodityCont").val();

        var commodityImage =$("#commodityImage").val();

        if(commodityName==""||commodityName==undefined){
            $("#msgmore").html("请输入商品名字").show();
            setTimeout(function () {
                $("#msgmore").hide();
            }, 3000);
            return
        }else if(commodityIntegral==""||commodityIntegral==undefined){
            $("#msgmore").html("请输入商品积分").show();
            setTimeout(function () {
                $("#msgmore").hide();
            }, 3000);

            return
        }else if(commodityCont==""||commodityCont===undefined){
            $("#msgmore").html("请输入商品数量").show();
            setTimeout(function () {
                $("#msgmore").hide();
            }, 3000);

            return
        }else if(commodityImage==""||commodityImage===undefined) {
            $("#msgmore").html("请输入商品图片").show();
            setTimeout(function () {
                $("#msgmore").hide();
            }, 3000);
            return
        }
        $("#svemp").removeAttr("disabled");
    }

    function add() {
        var in1=$("#commodityImage").val();
        $("#in1").val(in1);
        $("#save_emp").submit();
    }
</script>
</body>
</html>